;my .emcas
;;define key
(global-set-key [f6] 'call-last-kbd-macro)
(global-set-key [f7] 'calendar)
(global-set-key "\C-c\C-m" 'execute-extended-command)
(global-set-key (kbd "C-c C-q") 'indent-region)
(global-set-key (kbd "C-c k") 'kill-this-buffer)
(global-set-key (kbd "C-c C-r") 'comment-or-uncomment-region)
(global-set-key (kbd "C-c C-w") 'copy-word)

;;------------------启动时最大化
(defun my-fullscreen ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(2 "_NET_WM_STATE_FULLSCREEN" 0)))

;最大化
(defun my-maximized-horz ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
(defun my-maximized-vert ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
(defun my-maximized ()
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(1 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
  (interactive)
  (x-send-client-message
   nil 0 nil "_NET_WM_STATE" 32
   '(1 "_NET_WM_STATE_MAXIMIZED_VERT" 0)))
(global-set-key [f11] 'my-fullscreen)

;scroll other window
;(global-set-key (kbd "C-c C-v") 'scroll-other-window)
;(global-set-key (kbd "C-c C-b") 'scroll-other-window-down)

(setq x-select-enable-clipboard t)
;;------add orgtbl minor mode to text-mode and mail-mode
(add-hook 'text-mode-hook 'turn-on-orgtbl)
(add-hook 'mail-mode-hook 'turn-on-orgtbl)
(tool-bar-mode -1);去除工具栏
(scroll-bar-mode -1)
(menu-bar-mode -1)
(column-number-mode t);display column number
;(transient-mark-mode);Highlighted region
(require 'jka-compr);deal with compressed files
(setq bookmark-save-flag 1)
(setq default-tab-width 4)
;;关闭emacs启动时的画面
;;(setq inhibit-startup-screen t)
;;关闭烦人的出错时的提示声
(setq visible-bell t)
;;光标靠近鼠标指针时，让鼠标指针自动让开，别挡住视线。
(setq mouse-avoidance-mode 'animate)
;; 在行首C-k 时，同时删除该行。
(setq-default kill-whole-line t)
;; 当光标在行尾上下移动的时候，始终保持在行尾。
(setq track-eol t)
;;设置缺省模式是text，而不是基本模式
(setq default-major-mode 'text-mode)
;(setq initial-major-mode 'my-agenda)
(add-hook 'text-mode-hook 'turn-on-auto-fill)
;;防止页面滚动时跳动
(setq scroll-margin 3
      scroll-conservatively 10000)
;;开启语法高亮。
(global-font-lock-mode 1)
(setq default-directory "/home/xh/mp/") ;;设置初始目录
;;显示匹配的括号
(show-paren-mode t)
(setq show-paren-style 'parentheses)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; emacs自带python mode，回车后自动缩进
(add-hook
 'python-mode-hook '(lambda()
                     (local-set-key "\r"
                                    '(lambda()
                                       (interactive)
                                       (insert "\n")
                                       (python-indent-line)))))

(put 'upcase-region 'disabled nil)
(add-hook 'python-mode-hook 'my-python-hook)

(defun py-outline-level ()
;;"This is so that `current-column` DTRT in otherwise-hidden text"
;; from ada-mode.el
 (let (buffer-invisibility-spec)
     (save-excursion
       (skip-chars-forward "\t ")
       (current-column))))

; this fragment originally came from the web somewhere, but the outline-regexp
; was horribly broken and is broken in all instances of this code floating
; around. Finally fixed by Charl P. Botha <<a href="http://cpbotha.net/">http://cpbotha.net/</a>>
(defun my-python-hook ()
(setq outline-regexp "[^ \t\n]\\|[ \t]*\\(def[ \t]+\\|class[ \t]+\\)")
; enable our level computation
(setq outline-level 'py-outline-level)
; do not use their \C-c@ prefix, too hard to type. Note this overides
;some python mode bindings
(setq outline-minor-mode-prefix "\C-j")
; turn on outline mode
(outline-minor-mode t)
; initially hide all but the headers
;(hide-body)
(show-paren-mode 1)
)
;;;;--------------java mode---------------
(add-hook 'java-mode-hook 'my-java-hook)
(defun my-java-hook()
 ;;缩进距离
(setq default-tab-width 4)
;;方便的编译配置,按f7，回车，编译源代码，按f6运行class文件
(setq compile-command (concat "javac " buffer-file-name))
(defun run-java()
(interactive)
(shell-command (concat "java " (car (reverse (split-string (car (split-string buffer-file-name "[\.]" t)) "/" t)))))
)
(local-set-key  [(f6)] 'run-java)
;;hungry-delete模式打开
(c-toggle-hungry-state t)
(outline-minor-mode t)
;;缩写模式打开
(setq abbrev-mode t)
;;ctrl-c p输出System.out.println
(defun start-print-block ()
(interactive)
(insert "System.out.println();")
(backward-char 3)
)
(local-set-key  (kbd "C-c p") 'start-print-block)
;;自动补全的快捷键
;(local-set-key (kbd "TAB") 'hippie-expand)
;;代码折叠的键绑定
;;(local-set-key  [M-left] 'outline-hide-subtree)
;;(local-set-key [M-right] 'outline-show-subtree)
;;(local-set-key (kbd "C-o C-l") 'hs-hide-level)
)
;;自动补全花括号
(defun my-java-mode-auto-pair ()
  (interactive)
  (make-local-variable 'skeleton-pair-alist)
  (setq skeleton-pair-alist  '(
    (?{ \n > _ \n ?} >)))
  (setq skeleton-pair t)
  (local-set-key (kbd "{") 'skeleton-pair-insert-maybe)
)
(add-hook 'java-mode-hook 'my-java-mode-auto-pair)

;;设置java缩写词
(define-abbrev-table 'java-mode-abbrev-table '(
    ("imp" "implements" c-electric-continued-statement 0)
    ("syn" "synchronized" c-electric-continued-statement 0)
   ("ab" "abstract" c-electric-continued-statement 0)
("pro" "protected" c-electric-continued-statement 0)  
 ))

;;;-------------------------outline minor mode------------------------
(global-set-key [M-left] 'hide-subtree)
(global-set-key [M-right] 'show-subtree)
(global-set-key [M-up] 'outline-previous-heading)
(global-set-key [M-down] 'outline-next-heading)
(global-set-key [C-M-left] 'hide-sublevels)
(global-set-key [C-M-right] 'show-children)
(global-set-key [C-M-up] 'outline-previous-visible-heading)
(global-set-key [C-M-down] 'outline-next-visible-heading)
;;ido mode-------------------------
(require 'ido)
(ido-mode t)

(global-set-key [(f2)] 'speedbar)
;; Treat 'y' or <CR> as yes, 'n' as no.--------------------------------------
(fset 'yes-or-no-p 'y-or-n-p)
(define-key query-replace-map [return] 'act)
(define-key query-replace-map [?\C-m] 'act)
;;copy line,word,paragraph--------------------------------------
(defun copy-line (&optional arg)
 "Save current line into Kill-Ring without mark the line"
 (interactive "P")
 (let ((beg (line-beginning-position))
    (end (line-end-position arg)))
 (copy-region-as-kill beg end))
)

(defun copy-word (&optional arg)
 "Copy words at point"
 (interactive "P")
 (let ((beg (progn (if (looking-back "[a-zA-Z0-9]" 1) (backward-word 1)) (point)))
    (end (progn (forward-word arg) (point))))
 (copy-region-as-kill beg end))
)

(defun copy-paragraph (&optional arg)
 "Copy paragraphes at point"
 (interactive "P")
 (let ((beg (progn (backward-paragraph 1) (point)))
    (end (progn (forward-paragraph arg) (point))))
 (copy-region-as-kill beg end))
)

;; 所有的备份文件转移到~/backups目录下
(setq backup-directory-alist (quote (("." . "~/emacs/backups"))))
(setq version-control t)
(setq kept-old-versions 2)
(setq kept-new-versions 5)
(setq delete-old-versions t)
(setq backup-directory-alist '(("." . "~/emacs/backups")))
(setq backup-by-copying t)
;;delete the auto save files when exit
(setq delete-auto-save-files t)
;; ;;-------------php-mode-------------------------------------------
(require 'php-mode)
(define-key php-mode-map
     [menu-bar php php-debug]
     '("PHP Debug" . php-debug))
(define-key php-mode-map
     [menu-bar php php-run]
     '("Run PHP" . php-run))
(defun php-debug ()
    (interactive)
    (shell-command
     (concat "php -l \"" (buffer-file-name) "\"")))
(defun php-run ()
     (interactive)
     (shell-command
      (concat "php -q \"" (buffer-file-name) "\"")))
(defun my-php-mode()
   ;; 将回车代替C-j的功能，换行的同时对齐
     (define-key php-mode-map [return] 'newline-and-indent)
     (define-key php-mode-map [(control c) (r)] 'php-run)
     (define-key php-mode-map [(control c) (d)] 'php-debug)
     (interactive)
   ;; 设置php程序的对齐风格
     (c-set-style "K&R")
 ;;; hungry-delete and auto-newline
     (c-toggle-auto-hungry-state 1)
   ;; 此模式下，当按Backspace时会删除最多的空格
     (c-toggle-hungry-state)
   ;; TAB键的宽度设置为4
     (setq c-basic-offset 4)
   ;; 在菜单中加入当前Buffer的函数索引
	 (c-toggle-auto-state)
   ;; 在状态条上显示当前光标在哪个函数体内部
     (which-function-mode 1)
     )
(add-hook 'php-mode-hook 'my-php-mode)
;; ;;(add-to-list 'auto-mode-alist '("\\.php$" . my-php-mode))
(add-hook 'php-mode-hook
	  '(lambda ()
	    (require 'xcscope)))
;; ;;----------------------------------------------------------
;; ;;Create MyCppStyle
;; (defconst MyCppStyle
;; '((c-tab-always-indent . t)
;;     (c-comment-only-line-offset . 0)
;; 	(c-hanging-braces-alist . ((substatement-open after)
;; 							   (brace-list-open)))
;; 	(c-cleanup-list . (comment-close-slash
;; 					   compact-empty-funcall))
;;     (c-offsets-alist . ((substatement-open . 0)
;; 						(innamespace . 0)                           ;;在namespace中不缩进
;; 						(case-label      . +)                          ;;case标签缩进一个c-basic-offset单位
;; 						(access-label . -)                             ;;private/public等标签少缩进一单位
;; 						(inline-open . 0)                             ;;在.h文件中写函数，括号不缩进
;; 						(block-open     . 0)))                       ;;在一个新块开始时不缩进
;; 	;;    (c-echo-syntactic-information-p t)
;; 	(setq comment-start "/*"
;; 		  comment-end "*/")
;;     (setq indent-tabs-mode nil)
;; 	)
;; "My Cpp Coding Style")
;; (c-add-style "MyCppStyle" MyCppStyle)                   ;;定义完自己的style，将其添加到cc-mode的style中。
;; ;;Define own hook
;; ;; (defun MyCppHook ()
;; ;; (company-mode)
;; ;; (setq indent-tabs-mode nil)
;; ;; (setq c-hanging-braces-alist nil)
;; ;; (setq global-hl-line-mode t)
;; ;; (c-set-style "MyCppStyle"))                                   ;;设置这个hook对应于MyCppStyle
;; ;; (add-hook 'c++-mode-hook 'MyCppHook)                ;;将此hook应用于所有的c++模式。

;; ;;我的C/C++语言编辑策略
;; ;;; Esay Edit for C++/C programming
;; ;;TAB and RET auto align and indent
;; (add-hook 'c++-mode-hook
;;    (lambda ()
;;      ;;bsd,stroustrup,k&r
;; ;;     (c-set-style "bsd")
;;      (c-set-style "stroustrup")
;;      (setq c-continued-brace-offset 0)
;;      (setq c-continued-statement-indent 0)
;; 	 (c-set-style "MyCppStyle")
;;      (setq c-brace-offset 0)
;;      (setq indent-tabs-mode nil)
;;      (setq c-hanging-braces-alist nil)
;;    ;; TAB键的宽度设置为4
;;      (setq c-basic-offset 4)
;;      ;; hungry-delete and auto-newline
;;      (c-toggle-auto-hungry-state 1)
;;      ;; 在菜单中加入当前Buffer的函数索引
;;      (imenu-add-menubar-index)
;;      ;; 在状态条上显示当前光标在哪个函数体内部
;;      (which-function-mode)
;;      (hs-minor-mode)
;;      (local-set-key "\C-c\t" 'complete-symbol)
;;      (local-set-key "\C-m" 'newline-and-indent)
;;      (setq mslk-c++-key (make-keymap))
;;      (local-set-key "\C-j" mslk-c++-key)
;;      (define-key mslk-c++-key "\C-j" 'complete-symbol)
;;      (define-key mslk-c++-key "\C-o" 'hs-hide-all)
;;      (define-key mslk-c++-key "\C-p" 'hs-show-all)
;;      (define-key mslk-c++-key "\C-h" 'hs-hide-block)
;;      (define-key mslk-c++-key "\C-s" 'hs-show-block)
;;      (define-key mslk-c++-key "\C-l" 'hs-hide-level)
;;      (define-key mslk-c++-key "\C-m" 'hs-toggle-hiding)
;; 	 (define-key c-mode-base-map [(f5)] 'compile)
;; 	 (define-key c-mode-base-map [(f8)] 'ff-get-other-file)
;; 	 (define-key c-mode-base-map [(f9)] 'gdb)
;;      ))
;; (add-hook 'c-mode-hook 'c++-mode)
;; ;;;;根据后缀判断所用的mode
;; ;;;;注意：我在这里把.h关联到了c++-mode
(setq auto-mode-alist
       (append '(("\\.h$" . c++-mode)) auto-mode-alist))
;; ;; (add-hook 'c++-hook
;; ;; 	  '(lambda ()
;; ;; 	    (require 'xcscope)))
(add-to-list 'load-path "/home/xh/emacs/lib")
(require 'google-c-style)
(add-hook 'c-mode-common-hook 'google-set-c-style)
(add-hook 'c-mode-common-hook 'google-make-newline-indent)
;;-------------js-mode-------------------------------------------
(add-to-list 'auto-mode-alist '("\\.js\\'" . javascript-mode))
(autoload 'javascript-mode "javascript" nil t)

;;-------------------- tabbar------------------------
(require 'tabbar)
;设置tabbar字体-----说明，下面这段要加在tabbar之后。
(set-face-attribute 'tabbar-default-face
          nil :family "Tahoma")
(tabbar-mode t)
(global-set-key (kbd "M--") 'tabbar-backward-group)
(global-set-key (kbd "M-=") 'tabbar-forward-group)
(global-set-key (kbd "M-1") 'tabbar-backward)
(global-set-key (kbd "M-2") 'tabbar-forward)

;;------------------gdb-many-window,use M-x gdb-----
;;http://www.inet.net.nz/~nickrob/
(setq gdb-many-windows t)
(load-library "multi-gud.el")
(load-library "multi-gdb-ui.el")
;;---------session----------------------------------
;保存上次的操作记录到SESSION
(add-to-list 'load-path "~/tmp")
(require 'session)
(add-hook 'after-init-hook 'session-initialize)
;;----------pymacs----------------------------------
;(autoload 'pymacs-apply "pymacs")
;(autoload 'pymacs-call "pymacs")
;(autoload 'pymacs-eval "pymacs" nil t)
;(autoload 'pymacs-exec "pymacs" nil t)
;(autoload 'pymacs-load "pymacs" nil t)
;;----------------hippie-expand---------------------
(global-set-key (kbd "M-/") 'hippie-expand)
 (defun he-tag-beg ()
   (let ((p
          (save-excursion
            (backward-word 1)
            (point))))
     p))

(defun try-expand-tag (old)
  (unless  old
    (he-init-string (he-tag-beg) (point))
    (setq he-expand-list (sort
                          (all-completions he-search-string 'tags-complete-tag) 'string-lessp)))
  (while (and he-expand-list
              (he-string-member (car he-expand-list) he-tried-table))
              (setq he-expand-list (cdr he-expand-list)))
  (if (null he-expand-list)
      (progn
        (when old (he-reset-string))
        ())
    (he-substitute-string (car he-expand-list))
    (setq he-expand-list (cdr he-expand-list))
    t))

(setq hippie-expand-try-functions-list
      '(try-expand-all-abbrevs try-expand-dabbrev
 try-expand-dabbrev-all-buffers try-expand-dabbrev-from-kill
 try-complete-lisp-symbol-partially try-complete-lisp-symbol
 try-complete-file-name-partially try-complete-file-name try-expand-tag))
;;-----------------calendar-------------------
;;设置我所在地方的经纬度，calendar里有个功能是日月食的预测，和你的经纬度相联系的。
;; 让emacs能计算日出日落的时间，在 calendar 上用 S 即可看到
(setq calendar-latitude +39.54)
(setq calendar-longitude +116.28)
(setq calendar-location-name "北京")
(setq calendar-remove-frame-by-deleting t)
(setq mark-diary-entries-in-calendar t)     ; 标记calendar上有diary的日期
(setq mark-holidays-in-calendar nil)        ; 为了突出有diary的日期，calendar上不标记节日
(setq diary-file "/home/xh/emacs/diary")
(setq view-calendar-holidays-initially nil) ; 打开calendar的时候不显示一堆节日
;; 去掉不关心的节日，设定自己在意的节日，在 calendar 上用 h 显示节日
(setq christian-holidays nil)
(setq hebrew-holidays nil)
(setq islamic-holidays nil)
(setq solar-holidays nil)
(setq general-holidays '((holiday-fixed 1 1 "元旦")
            (holiday-fixed 2 14 "情人节")
            (holiday-fixed 4 1 "愚人节")
            (holiday-fixed 5 1 "劳动节")
            (holiday-float 5 0 2 "母亲节")
            (holiday-fixed 6 1 "儿童节")
            (holiday-float 6 0 3 "父亲节")
            (holiday-fixed 7 1 "建党节")
            (holiday-fixed 8 1 "建军节")
            (holiday-fixed 9 10 "教师节")
            (holiday-fixed 10 1 "国庆节")
            (holiday-fixed 12 25 "圣诞节")))
;;打开约会提醒功能
;;M-x appt-add 加入新的约会提醒
;;M-x appt-delete 删除提醒
(setq appt-issue-message t)
(setq cal-html-directory "/home/xh/emacs/emacs/public_html/")
;;----------------org-mode--------------------
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(global-font-lock-mode 1) ; for all buffers
(add-hook 'org-mode-hook 'turn-on-font-lock) ; Org buffers only
(setq org-agenda-files (list "/home/xh/emacs/org/todo.org"
                             "/home/xh/emacs/org/emacs.org"
                             "/home/xh/emacs/org/notes.org"
							 "/home/xh/emacs/org/worklog.org"))
;;include entries from hte Emacs diary
(setq org-agenda-include-diary t)
;;when a todo item finished,record the time and a note
(setq org-log-done 'time)
;(setq org-log-done 'note)
(setq org-tag-alist '(("NotUsed" . ?n) ("Unsure" .?u) ("revise" . ?r) ("solved" . ?s)("important" .?i) ("point" .?p) ))
;;---------remember-------------------------------------
;;set up remember,tell it to use org files as target
;;(add-to-list 'load-path "/usr/share/emacs/site-lisp/remember-2.0/")
(org-remember-insinuate)
(setq org-directory "/home/xh/emacs/org/")
(setq org-default-notes-file (concat org-directory "notes.org"))
(define-key global-map "\C-cr" 'org-remember)

(autoload 'remember "remember" nil t)
(autoload 'remember-region "remember" nil t)
(define-key global-map (kbd "<f8> r") 'remember)
(define-key global-map (kbd "<f8> R") 'remember-region)

(setq org-remember-templates
      '(("Todo" ?t "* TODO %?\n  %i\n" "/home/xh/emacs/org/todo.org" "Tasks")
        ("Note" ?n "* %^{Title} %U\n %?  %i" "/home/xh/emacs/org/notes.org" bottom)
        ("Idea" ?i "* %^{Title} %t\n %? %i" "/home/xh/emacs/org/journal.org" "New Ideas")
        ("Worklog" ?w "* %t %?\n %i" "/home/xh/emacs/org/worklog.org")))
;;--------------------ecb--------------------------
(load-file "/usr/local/share/emacs/site-lisp/cedet-1.0pre6/common/cedet.el")
;; Enable EDE (Project Management) features
(global-ede-mode 1)
;; Enable EDE for a pre-existing C++ project
;; (ede-cpp-root-project "NAME" :file "~/myproject/Makefile")

;; Enabling Semantic (code-parsing, smart completion) features
;; Select one of the following:

;; * This enables the database and idle reparse engines
;(semantic-load-enable-minimum-features)

;; * This enables some tools useful for coding, such as summary mode
;;   imenu support, and the semantic navigator
;;(semantic-load-enable-code-helpers)

;; * This enables even more coding tools such as intellisense mode
;;   decoration mode, and stickyfunc mode (plus regular code helpers)
;; (semantic-load-enable-gaudy-code-helpers)

;; * This enables the use of Exuberent ctags if you have it installed.
;;   If you use C++ templates or boost, you should NOT enable it.
;; (semantic-load-enable-all-exuberent-ctags-support)

;; Enable SRecode (Template management) minor-mode.
;; (global-srecode-minor-mode 1)
 ;;设置检索范围
 (setq semanticdb-project-roots
   (list
         (expand-file-name "/")));;可以设置为项目的顶级目录
;;绑定按键,ctr+tab,以下三种,任意选择一个,我喜欢第二个
;; (global-set-key [(control tab)] 'senator-complete-symbol);
(global-set-key [(control tab)] ' senator-completion-menu-popup)
 ;; (global-set-key [(control tab)] 'semantic-ia-complete-symbol-menu)

;;;;;;;;;;;-----------------for matlab -----------------------
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/matlab-emacs")
(require 'matlab-load)
(autoload 'matlab-mode "matlab" "Enter MATLAB mode." t)
(setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist))
(autoload 'matlab-shell "matlab" "Interactive MATLAB mode." t)

(setq matlab-indent-function-body t)  ; if you want function bodies indented
(setq matlab-verify-on-save-flag nil) ; turn off auto-verify on save
(defun my-matlab-mode-hook ()
  (setq fill-column 76))		; where auto-fill should wrap
(add-hook 'matlab-mode-hook 'my-matlab-mode-hook)
(defun my-matlab-shell-mode-hook ()
  '())
(add-hook 'matlab-shell-mode-hook 'my-matlab-shell-mode-hook)

(add-hook 'matlab-mode-hook
	  '(lambda ()
	    (require 'xcscope)))

;;To get font-lock try adding this for older emacsen:
;;(font-lock-mode 1)
;; Or for newer versions of Emacs:
;;(global-font-lock-mode t)
;; To get hilit19 support try adding:
;;(matlab-mode-hilit)

;;;;--------------------ecb---
;;;;(add-to-list 'load-path
;;;;         "/usr/local/share/emacs/site-lisp/ecb-2.32")
(require 'ecb)
(global-set-key [f12] 'ecb-activate) ;;定义F12键为激活ecb
(global-set-key [C-f12] 'ecb-deactivate) ;;定义Ctrl+F12为停止ecb

(semantic-load-enable-semantic-debugging-helpers)
(setq semantic-load-turn-everything-on nil)
(setq-default semantic-idle-scheduler-idle-time 432000)

(setq
ecb-use-speedbar-instead-native-tree-buffer 'source
ecb-layout-name "left6"
ecb-primary-secondary-mouse-buttons 'mouse-1--C-mouse-1
ecb-windows-width 0.20
ecb-tip-of-the-day nil
)
(global-set-key (kbd "C-c s") 'ecb-goto-window-sources)
(global-set-key (kbd "C-c m") 'ecb-goto-window-methods)
(global-set-key (kbd "C-c d") 'ecb-goto-window-directories)
(global-set-key (kbd "C-c h") 'ecb-goto-window-history)
;;---------------custom--------------
(setq kill-read-only-ok nil)
;;====================================================================
(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(browse-url-browser-function (quote browse-url-default-windows-browser))
 '(browse-url-generic-program "firefox")
 '(ecb-options-version "2.32")
 '(face-font-family-alternatives (quote (("serif" "fixed") ("helv" "helvetica" "arial" "fixed"))))
 '(inhibit-startup-screen t)
 '(org-agenda-files (quote ("/home/xh/emacs/org/journal.org" "/home/xh/emacs/org/todo.org" "/home/xh/emacs/org/notes.org")))
 '(speedbar-show-unknown-files t)
 '(speedbar-use-images t))
(custom-set-faces
 '(font-lock-comment-face ((nil (:foreground "MistyRose3" :slant normal)))))
;;======================配色方案=================================
 ;;  (setq default-frame-alist
 ;;  '(
 ;;     (foreground-color . "Wheat")
 ;;     (background-color . "DarkSlateGray")
 ;;     (cursor-color     . "Orchid")
 ;;    )
 ;; )
;;(set-foreground-color "black")
;;(set-background-color "#CCE8CF")
;;#CCE8CF  rgb(204, 232, 207) 
;;让 Emacs 可以直接打开和显示
(setq auto-image-file-mode t)
(setq user-full-name "xiaohui yan")
(setq user-mail-address "l0he1g@gmail.com")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;   显示时间设置   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(display-time-mode 1);;启用时间显示设置，在minibuffer<上面的那个杠上
(setq display-time-24hr-format t);;时间使用24小时制
(setq display-time-day-and-date t);;时间显示包括日期和具体时间
;(setq display-time-use-mail-icon t);;时间栏旁边启用邮件设置
(setq display-time-interval 10);;时间的变化频率，单位多少来着？
;========================FONT SETS FOR LINUX=================================
; (create-fontset-from-fontset-spec
; "-*-yahei mono-medium-r-normal--15-*-*-*-*-*-fontset-yahei")
; (set-default-font "fontset-yahei")
; (setq default-frame-alist
; (append
; '((font . "fontset-yahei")) default-frame-alist))
;;====================scroll screen left and right=================
(put 'scroll-left 'disabled nil)     ;允许屏幕左移
(put 'scroll-right 'disabled nil)    ;允许屏幕右移
(global-set-key (kbd "C-.") 'scroll-left)
(global-set-key (kbd "C-,") 'scroll-right)
;===================for auctex====================
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
;;设置xetex为默认编辑命令，evince为pdf文件阅读器
;(setq TeX-output-view-style (quote (("^pdf$" "." "foxit %o %(outpage)"))))
 (eval-after-load "tex"
   '(progn
      (TeX-global-PDF-mode t)
      (setq TeX-output-view-style
          (cons '("^pdf$" "." "evince %o") TeX-output-view-style)
       )))

(add-hook 'LaTeX-mode-hook
(lambda()
(add-to-list 'TeX-command-list '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
(setq TeX-command-default "XeLaTeX")))
;;一键编译预览
;;(fset 'pdflatex-or-view [?\C-c ?\C-c]) 
;(add-hook 'LaTeX-mode-hook (define-key LaTeX-mode-map [(f10)] 'pdflatex-or-view))

 ;; minor;;  modes
 ;; (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
 ;; (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
 ;; (autoload 'reftex-citation "reftex-cite" "Make citation" nil)  
 ;; (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
 ;; (autoload 'cdlatex-mode "cdlatex" "CDLaTeX Mode" t)
 ;; (autoload 'turn-on-cdlatex "cdlatex" "CDLaTeX Mode" nil)
;;  (add-hook 'TeX-mode-hook
;;           (lambda ()
;;             (turn-on-reftex)
;;             (auto-fill-mode)
;;             (outline-minor-mode)
;;             (flyspell-mode)))
;;   (add-hook 'LaTeX-mode-hook
;;           (lambda ()
;;             (LaTeX-math-mode)
;; ;;            (turn-on-cdlatex)
;;             (turn-on-reftex)
;;             (auto-fill-mode)
;;             (outline-minor-mode)
;;             (flyspell-mode)))
;; (setq reftex-section-levels
;;      '(("part" . 0) ("chapter" . 1) ("section" . 2) ("subsection" . 3)
;;        ("frametitle" . 4) ("subsubsection" . 4) ("paragraph" . 5)
;;        ("subparagraph" . 6) ("addchap" . -1) ("addsec" . -2)))
;; (setq flyspell-sort-corrections nil)
;; (defun my-flyspell-ignore-uppercase (beg end &rest rest)
;;  (while (and (< beg end)
;;              (let ((c (char-after beg)))
;;                (not (= c (downcase c)))))
;;    (setq beg (1+ beg)))
;;  (= beg end))
;; (add-hook 'flyspell-incorrect-hook 'my-flyspell-ignore-uppercase)


;========================FONT SETS FOR LINUX=================================
(set-default-font "Yahei Mono-12")
(set-fontset-font (frame-parameter nil 'font)
              'gb18030 '("Yahei Mono" . "unicode-bmp"))
(set-fontset-font (frame-parameter nil 'font)
              'symbol '("WenQuanYi Bitmap Song" . "unicode-bmp"))